home *** CD-ROM | disk | FTP | other *** search
- Path: news.dal.ca!news
- From: Klaus.Eichele@Dal.Ca (Klaus Eichele)
- Newsgroups: comp.lang.c
- Subject: Re: FLOATING POINT PROBLEM
- Date: Mon, 01 Apr 1996 16:55:36 GMT
- Organization: Dalhousie University
- Message-ID: <4jojoa$aa6@News.Dal.Ca>
- References: <4joeof$hoc@newsbf02.news.aol.com>
- NNTP-Posting-Host: rewasylishen.chem.dal.ca
- X-Newsreader: Forte Free Agent 1.0.82
-
- maddawson@aol.com (MADDawson) wrote:
-
- >I have been working on a Windows program. The prog compiles correctly
- >without any warnings or errors. When I add something that tries to get a
- >float value from a string, the program quits running. It does this in and
- >out of the IDE.
-
- >I have erased the project and copied a project from another program and I
- >get the same results. I have re-created the project from scratch and
- >still no luck.
-
- >I have included every .h file I would think would have something to do
- >with it. I would REALLY appreciate some help with this as I have compiled
- >a similar program correctly and have not had this problem before. I would
- >think it might be a compiler setting or something NOT in the program
- >itself.
-
- >I have included the following lines.
-
- >float part_number;
- >char buffer[100];
-
- >I get the value of the edit control using GetDlgItemText and put into
- >buffer. (This works as I have a MessageBox that shows the value.
-
- >Then I try:
-
- >part_number = atof(buffer);
-
- >This is where the prog stops.
-
- >I have also tried:
-
- >sscanf(buffer, "%f", &part_number);
-
- >It stops here, too. (I have used this line in another prog and it works
- >correctly.
-
- >Again, I would really appreciate any help I receive on this.
-
- Hi,
- you didn't specify which compiler you are using. If you are using a
- version of Borland's C++ compilers, my first guess would be a
- "floating point format not linked error". From the Borland README.TXT
- file:
-
- ===========================================================
- 2. CAUSE: Either the compiler is over-optimizing, or the
- floating-point formats really do need to be linked in because
- your program manipulates floats in a limited and specific
- fashion. Under certain obscure conditions, the compiler will
- ignore floating point usage in scanf() (e.g., trying to
- read into a float variable that is part of an array contained
- in a structure.)
-
- FIX: Add the following to one source module:
-
- extern _floatconvert;
- #pragma extref _floatconvert
-
- ==============================================================
- Good Luck,
- Klaus
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Klaus Eichele keichele@is.dal.ca
- http://is.dal.ca/~keichele/keichele.html
-
-